<?php

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

class Operat_Mod extends CI_Model {
	function __construct() {
		parent::__construct ();
		$this->load->database ();
	}
	
	public function create() {
		
		$data = array ('username' => $_POST ["username"], 'password' => $_POST ["userpass"], //'type_id' => $_POST[""],
		'create_time' => $_POST ["time"] );
		$this->db->insert ( 'operat', $data );
	}
	
	public function read_all() {
		$this->db->select ( 'id, username,password,type_id,create_time' );
		$query = $this->db->get ( 'operat' );
		return $query->result ();
	
	}
	
	public function read_byid($id) {
		$this->db->select ( 'id, username,password,type_id,create_time' );
		$query = $this->db->get_where ( 'operat', array ('id' => $id ) );
		return $query->result ();
	}
	
	public function updata_byid($id) {
		$data = array ('username' => $_POST ["username"], 'password' => $_POST ["userpass"] )//'type_id' => $_POST[""],
		// 'create_time' => $_POST[""]
		;
		$this->db->where ( 'id', $id );
		$this->db->update ( 'operat', $data );
	}
	
	public function delete($id) {
		$this->db->where ( 'id', $id );
		$this->db->delete ( 'operat' );
	}

}

?>
